/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.compomics.dataprovider.view.wizard.panels.input;

import java.util.Enumeration;
import javax.swing.AbstractButton;

/**
 *
 * @author Kenneth
 */
public class InputMethodPanel extends javax.swing.JPanel {

    /**
     * Creates new form InputMethodPanel
     */
    public InputMethodPanel() {
        initComponents();
        rbExisting.setSelected(true);
        rdbtnGroup.add(rbExisting);
        rdbtnGroup.add(rbTaxonomies);
        rdbtnGroup.add(rdBoth);
    }

    public int getSelectedOption() {
        for (Enumeration<AbstractButton> buttons = rdbtnGroup.getElements(); buttons.hasMoreElements();) {
            AbstractButton button = buttons.nextElement();
            if (button.isSelected()) {
                switch (button.getName()) {
                    case "fileBased":
                        return 1;
                    case "taxonomyBased":
                        return 2;
                }
            }
        }
        return 3;
    }

    public void reset() {
        rbExisting.setSelected(true);
        rbTaxonomies.setSelected(false);
        rdBoth.setSelected(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        rdbtnGroup = new javax.swing.ButtonGroup();
        rdBoth = new javax.swing.JRadioButton();
        rbTaxonomies = new javax.swing.JRadioButton();
        rbExisting = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();

        setBackground(null);

        rdBoth.setBackground(new java.awt.Color(255, 255, 255));
        rdBoth.setText("Both");
        rdBoth.setToolTipText("Use both existing FASTA-files and the taxonomy browser to select the input.");
        rdBoth.setName("taxonomyAndFileBased"); // NOI18N

        rbTaxonomies.setBackground(null);
        rbTaxonomies.setText("Taxonomies from UniProt");
        rbTaxonomies.setToolTipText("Select taxonomies using the taxonomybrowser.");
        rbTaxonomies.setName("taxonomyBased"); // NOI18N

        rbExisting.setBackground(null);
        rbExisting.setText("Existing FASTA-files");
        rbExisting.setToolTipText("Use only FASTA-files that already exist.");
        rbExisting.setName("fileBased"); // NOI18N

        jLabel2.setText("What will the input be for the creation of the FASTA-file ?");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rdBoth)
                    .addComponent(rbTaxonomies)
                    .addComponent(jLabel2)
                    .addComponent(rbExisting))
                .addContainerGap(115, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(rbExisting)
                .addGap(18, 18, 18)
                .addComponent(rbTaxonomies)
                .addGap(18, 18, 18)
                .addComponent(rdBoth)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel2;
    private javax.swing.JRadioButton rbExisting;
    private javax.swing.JRadioButton rbTaxonomies;
    private javax.swing.JRadioButton rdBoth;
    private javax.swing.ButtonGroup rdbtnGroup;
    // End of variables declaration//GEN-END:variables

    public boolean getDownload() {
        return rdBoth.isSelected() | rbTaxonomies.isSelected();
    }
}
